def gerar_cubos(n):
    for i in range(n):
        yield i ** 3  # yield = expoente

gen = gerar_cubos(5)

print gen.next()
print gen.next()
print gen.next()
print gen.next()
print gen.next()

print
for y in gerar_cubos(5):
    print y
